#include <iostream>
#include <string>
#include <project_config.h>
#include <map>
#include <filesystem>


std::string version_name = "1.0 release";
std::string file_abs;



void print_help_info() {
    std::string help_content = R"(RootKiller Help:
 --help                                 查看帮助选项
 --version                              查看版本
 --ssh [host] [port] [user]             使用 ssh 破解模块
 --ftp [host] [port] [user]             使用 ftp 破解模块
 --mysql [host] [port] [user]           使用 mysql 破解模块
 --wifi [wifi_name]                     使用 WIFI 破解模块
 --dict_make                            生成字典控制台
 --config                               配置编辑控制台
    )";
    std::cout << help_content << std::endl;
}

int main(int argc, char* argv[]) {
    file_abs = get_file_dir_linux(std::string(argv[0]));
    load_jmap_config(file_abs+"/config/config.jmap");

    // 设置新的工作目录
    std::filesystem::path newDir = file_abs; 
    current_path(newDir);
    try{
        /* code */
        // The First args
        std::string first_args = std::string(argv[1]);
        if (first_args == "--version") 
        {
            std::cout << version_name << std::endl;
        }
        else if (first_args == "--help") {
            print_help_info();
        }
        else if (first_args == "--config") {
            config_console(file_abs);
        }
        else if (first_args == "--ssh") {
            std::string host = std::string(argv[2]);
            int port = stoi(string(argv[3]));
            std::string username = std::string(argv[4]);

            run_ssh_attack_module(host , port , username);
        }
        else if (first_args == "--ftp") {
            std::string host = std::string(argv[2]);
            int port = stoi(string(argv[3]));
            std::string username = std::string(argv[4]);
        
            run_ftp_attack_module(host , port , username);
        }
        else if (first_args == "--ftp") {
            std::string host = std::string(argv[2]);
            int port = stoi(string(argv[3]));
            std::string username = std::string(argv[4]);
        
            run_mysql_attack_module(host , port , username);
        }
        else if (first_args == "--wifi") {
            std::string wifi = std::string(argv[2]);
            run_wifi_attack_module(wifi);
        }
        else if (first_args == "--dict_make") {
            make_dict_console();
        }
        else {
            std::cout << "[ERR] Need Input Value!" << std::endl; 
            print_help_info();
        }
    }
    catch(const std::exception& e){ std::cout << e.what() << endl; print_help_info();}
    return 0;
}